<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<base href="<%=basePath%>">
<html>
    
    <head>
        <meta charset="utf-8">
        <title>
            阳光成单系统
        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="System/css/x-admin.css" media="all">
    </head>
    
    <body>
        <div class="x-body">
            <form class="layui-form" method="post" action="employees/insertEmp">
                <div class="layui-form-item">
                    <label for="employeesName" class="layui-form-label">
                        <span class="x-black">姓&emsp;名</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="employeesName" name="employeesName" required="" lay-verify="required"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <%--@declare id="employeesage"--%><label for="employeesAge" class="layui-form-label">
                        <span class="x-black">年&emsp;龄</span>
                    </label>
                        <div class="layui-input-inline">
                            <input type="text" id="employeesAge" name="employeesAge" required="" lay-verify="required"
                                   autocomplete="off" class="layui-input">
                        </div>
                </div>
                <div class="layui-form-item">
                    <label for="employeesAddress" class="layui-form-label">
                        <span class="x-black">地&emsp;址</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="employeesAddress" name="employeesAddress" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="employeesUsername" class="layui-form-label">
                        <span class="x-black">账&emsp;号</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="employeesUsername" name="employeesUsername" required="" lay-verify="required"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="employeesPhone" class="layui-form-label">
                        <span class="x-black">手机号</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="employeesPhone" name="employeesPhone" required="" lay-verify="phone"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="employeesEmil" class="layui-form-label">
                        <span class="x-black">邮&emsp;箱</span>
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="employeesEmil" name="employeesEmil" required="" lay-verify="email"
                        autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <%--@declare id="roles"--%><label for="roles" class="layui-form-label">
                        <span class="x-black">角&emsp;色</span>
                    </label>
                    <div class="layui-input-inline">
                      <select name="role">
                        <option value="">全部角色</option>
                        <option value="1">超级管理员</option>
                        <option value="2">仓库管理员</option>
                        <option value="3">入库员</option>
                        <option value="4">出库员</option>
                        <option value="5">物流管理员</option>
                        <option value="6">配送员</option>
                      </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <%--@declare id="department"--%><label for="department" class="layui-form-label">
                        <span class="x-black">所在部门</span>
                    </label>
                    <div class="layui-input-inline">
                        <select name="department">
                            <option value="0">所有部门</option>
                            <option value="1">财务部</option>
                            <option value="2">人事部</option>
                            <option value="3">市场部</option>
                            <option value="4">仓储运输部</option>
                            <option value="5">总经理</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <%--@declare id="l_repass"--%><label for="L_repass" class="layui-form-label">
                    </label>
                    <button  class="layui-btn" lay-filter="add" lay-submit="" onclick="insert()">
                       立即添加
                    </button>
                </div>
            </form>
        </div>
        <script src="System/lib/layui/layui.js" charset="utf-8">
        </script>
        <script src="System/js/x-layui.js" charset="utf-8">
        </script>
        <script>
            layui.use(['form','layer'], function(){
                $ = layui.jquery;
              var form = layui.form()
              ,layer = layui.layer;
            
              //自定义验证规则
              form.verify({
                nikename: function(value){
                  if(value.length < 5){
                    return '昵称至少得5个字符啊';
                }
            }
            , pass: [/(.+){6,12}$/, '密码必须6到12位']
            , repass: function (value) {
                if ($('#L_pass').val() != $('#L_repass').val()) {
                    return '两次密码不一致';
                }
            }
        });
        //添加员工信息
        /*form.on('submit(add)', function(data){
           /!* alert(data);
            console.log(data);
            var employeesName=data.field.employeesName;//员工姓名
            var employeesAge=data.field.employeesAge;//员工年龄
            var employeesAddress=data.field.employeesAddress;//员工住址
            var employeesUsername=data.field.employeesUsername;//员工账号
            var employeesPhone=data.field.employeesPhone;//员工手机号
            var employeesEmil=data.field.employeesEmil;//员工邮箱
            location.href="employees/insertEmp?employeesName="+employeesName+"&employeesAge="+employeesAge+
                "employeesAddress="+employeesAddress+"employeesUsername="+employeesUsername+"employeesPhone="+employeesPhone+"employeesEmil="+employeesEmil;
            //发异步，把数据提交给java*!/
            // 获得frame索引
            var index = parent.layer.getFrameIndex(window.name);
            //关闭当前frame
            parent.layer.close(index);
            layer.alert("添加成功", {icon: 6,time:2000},function () {
            });
            return false;
        });*/
    });

    //转化为正整数
    function zhzs(value) {

        value = value.replace(/[^\d]/g, '');
        if ('' != value) {
            value = parseInt(value);
        }
        return value;
    }
</script>
<script>
    //添加员工信息
    function insert(){
        // 获得frame索引
        var index = parent.layer.getFrameIndex(window.name);
        //关闭当前frame
        parent.layer.close(index);
        layer.alert("添加成功", {icon: 6,time:2000},function () {
        });
    }
</script>
</body>

</html>